<extend file="resource/admin/common/common"/>
<block name="right_center">
    <!--右侧主题部分 start-->
    <div class="col-xs-12 col-sm-9 col-lg-10">
        <ol class="breadcrumb" style="background-color: #f9f9f9;padding:8px 0;margin-bottom:10px;">
            <li>
                <a href="{{u('index')}}"><i class="fa fa-cogs"></i>
                    轮播图管理</a>
            </li>
            <li class="active">
                <a href="javascript:;">轮播图添加</a>
            </li>
        </ol>
        <ul class="nav nav-tabs" role="tablist">
            <li><a href="{{u('index')}}">轮播图管理</a></li>
            <li class="active"><a href="javascript:;">轮播图添加</a></li>
        </ul>
        <form class="form-horizontal" id="form" onsubmit="return add()" action="" method="post">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">轮播图添加</h3>
                </div>
                <div class="panel-body">
                    <div class="form-group">
                        <label for="" class="col-sm-2 control-label">轮播图url</label>

                        <div class="col-sm-9">
                            <input type="text" name="lb_url" class="form-control" placeholder="轮播图url">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="" class="col-sm-2 control-label">缩略图</label>

                        <script src="resource/uploadify/jquery.uploadify.min.js"></script>
                        <link rel="stylesheet" href="resource/uploadify/uploadify.css">
                        <style>
                            .some-class{
                                background: rgba(221,90,37,.5);
                            }
                            #upload{
                                list-style:none;
                               margin-top: 10px;
                            }
                            #upload li{
                                float: left;
                                margin-right: 10px;
                            }
                        </style>
                        <div class="col-sm-9">
                            <div class="input-group">
                                <div class="input-group-btn">
                                    <input type="file" name="file_upload" id="file_upload" />
                                </div>
                                <script>
                                    $(function () {
                                        $("#file_upload").uploadify({
                                            height: 30,
                                            'removeTimeout' : 0.2,
                                            'buttonClass' : 'some-class',
                                            swf: 'resource/uploadify/uploadify.swf',
                                            uploader: "index.php?s=admin/article/upload",
                                            'buttonText' : '请选择图片',
                                            'onUploadSuccess' : function(file, data, response) {
                                                str ='<li><img src="'+data+'" alt="" height="50px" >';
                                                str+='<a href="javascript:;" class="delimg" path="'+data+'">X<a/>';
                                                str+='<input type="hidden" name="lb_img" value="'+data+'"/>'
                                                str+='</li>';
                                                $('#upload').append(str);

                                            },
                                            width: 120
                                        });
                                    });
                                </script>
                                <script>
                                        $(function(){
                                           $('#upload').on('click','.delimg',function(){
                                              var path=$(this).attr('path');
                                               that =$(this);
                                               $.ajax({
                                                   type: "POST",
                                                   url: "{{u('admin.article.delimg')}}",
                                                   data: {path:path},
                                                   dataType: "json",
                                                   success: function(msg){
                                                       if(msg){
                                                           that.parent('li').remove();
                                                       }
                                                   }
                                               });
                                           })
                                        })
                                </script>
                            </div>

                            <div id="upload">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <button class="btn btn-primary" type="submit">确定</button>
        </form>

    </div>
</block>
<!--右侧主题部分 end-->
